package com.bigevent.controller.user;


import com.bigevent.pojo.Article;
import com.bigevent.pojo.Category;
import com.bigevent.pojo.Result;
import com.bigevent.service.user.HostListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user")
public class HostListController {
    @Autowired
    private HostListService hostListService;


    @GetMapping("/article/list")
    public Result<List<Article>> hostList(){
        List<Article> list = hostListService.selectHostList();
        return Result.success(list);
    }

    @GetMapping("/article/{id}")
    public Result<Article> hostDetail(@PathVariable Integer id){
        Article article = hostListService.selectHostDetail(id);
        return Result.success(article);
    }

    /*
    * 浏览量增加
    * */
    @PutMapping("/article/{id}")
    public Result update(@PathVariable Integer id){
        hostListService.update(id);
        return Result.success();
    }

    /*
    * 点赞增加
    * */
    @PutMapping("/article/like/{id}")
    public Result like(@PathVariable Integer id){
        hostListService.like(id);
        return Result.success();
    }

    /*
    * 查看全部文章
    * */
    @GetMapping("/article/all")
    public Result<List<Article>> selectAll(){
        List<Article> list = hostListService.selectAll();
        return Result.success(list);
    }

    /*
    * 查看喜欢列表
    * */
    @GetMapping("/article/like")
    public Result<List<Article>> selectLike(){
        List<Article> list = hostListService.selectLike();
        return Result.success(list);
    }
}
